﻿@model Tasks.UI.Models.Article.ArticleModel
@{
    Layout = null;
}
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Bug任务</title>
    <link href="/css/main.css" rel="stylesheet" type="text/css" />
    <link href="@Config.GetCssResourcePath("table.css")" rel="stylesheet" type="text/css" />
    <link href="@Url.Content("~/Content/themes/base/jquery.ui.all.css")" rel="stylesheet" type="text/css" />
    <script src="@Url.Content("~/Scripts/jquery-1.5.1.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery-ui-1.8.11.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.validate.min.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/jquery.combobox.js")" type="text/javascript"></script>
    <script src="@Url.Content("~/Scripts/global.js")" type="text/javascript"></script>
    <script type="text/javascript">
        //init
        $(function () {
            datePicker("#InTime1");
            datePicker("#InTime2");
            initTable(".tblStyle1");
            $.ctrl.employeeDropdownList("OperatorName", "OperatorID");
            $.ctrl.employeeDropdownList("CreateUserName", "CreateUserID");
        })

        function goState(act) {
            $("#State").val(act);
            $("#PageIndex").val("1");
            $("#form1").submit();
        }

        function Delete(act, id) {
            $("#act").val(act);
            $("#ID").val(id);
            $("#PageIndex").val("1");
            $("#form1").submit();
        }

        function goOperator(id, name) {
            $("#OperatorID").val(id);
            $("#OperatorName").val(name);
            $("#PageIndex").val("1");
            $("#form1").submit();
        }

        function ConfirmDel(id, returnUrl) {
            $.Msg.confirmDelete(
             function () {
                 window.location = "/Bug/DeleteBug?ID=" + id + "&returnUrl=" + returnUrl;
             }
        );
        }

        function selectedType(type) {
            $("#Type").val(type);
            $("#PageIndex").val("1");
            goaction("search");
        }

        function goaction(act) {
            $("#act").val(act);
            $("#form1").submit();
        }

        function toEdit(url) {
            $.Dialog.openWindow(url,null, function (result) {
                if (result != undefined && result.dialogresult == "ok")
                    goaction("search");
            });        
        }

    </script>
    <style type="text/css">
        .tblStyle1
        {
            text-align: center;
        }
        .State_1 td
        {
            background-color: #F9F9F9;
        }
        .State_2 td
        {
            background-color: #FFFF99;
        }
        .State_3 td
        {
            background-color: #99CC66;
        }
        .State_4 td
        {
            background-color: #969696;
        }
        
        .testresult_1
        {
            display: block;
            width: 16px;
            height: 16px;
            background: url(/images/icon/16x16/check.png);
        }
        .testresult_2
        {
            display: block;
            width: 16px;
            height: 16px;
            background: url(/images/icon/16x16/alert.png);
        }
        .testresult_3
        {
            display: block;
            width: 16px;
            height: 16px;
            background: url(/images/icon/16x16/premium.png);
        }
        .tab1 span{ color:Red; font-weight:bold;}
        
        .tblStyle1 td.child_task_0 a{color:Blue;}
        .tblStyle1 td.child_task_0
        {
            text-align: left;
             font-weight:bold;
             color:Blue;
        }
        .tblStyle1 td.child_task_1 a{color:Green;}
        .tblStyle1 td.child_task_1
        {
            text-align: left;
            padding-left: 30px;
            color:Green;
        }
        .tblStyle1 td.child_task_2 a{color:Orange;}
        .tblStyle1 td.child_task_2
        {
            text-align: left;
            padding-left: 60px;
            color:Orange;
        }
    </style>
</head>
<body>
    @using (Html.BeginForm("BugList", "Bug", FormMethod.Post, new { id = "form1" }))
    {  
        @Html.HiddenFor(t => t.act)
        @Html.HiddenFor(t => t.ID)
        @Html.HiddenFor(t => t.State)
        @Html.HiddenFor(t => t.Type)
        <div id="container">
            @Html.OutputNavigation("任务列表", PageResult.cancel)
            <div class="searchBar">
                <div class="box">
                    <table>
                        <tr>
                            <td style="width: 80px;">
                                <strong>发布时间：</strong>
                            </td>
                            <td style="width: 250px;">
                                @Html.TextBoxFor(t => t.InTime1)<span>至</span>@Html.TextBoxFor(t => t.InTime2)
                            </td>
                            <td style="width: 60px;">
                                <strong>提出人：</strong>
                            </td>
                            <td style="width: 180px;">
                                @Html.HiddenFor(t => t.CreateUserID)
                                @Html.TextBoxFor(t => t.CreateUserName)
                            </td>
                            <td style="width: 60px;">
                                <strong>处理人：</strong>
                            </td>
                            <td style="width: 160px;">
                                @Html.HiddenFor(t => t.OperatorID)
                                @Html.TextBoxFor(t => t.OperatorName)
                            </td>
                            <td>
                                <input id="btnSearch" type="submit" class="btnSearch" value="查询" />
                            </td>
                        </tr>
                        <tr>
                            <td>
                                <strong>项目类型：</strong>
                            </td>
                            <td>
                                @Html.DropDownList("ProjectID", PageHelper.ProjectType(0))
                            </td>
                            <td>
                            </td>
                            <td>
                            </td>
                        </tr>
                    </table>
                    <div class="bottom">
                    </div>
                </div>
            </div>
            <div class="cpsoso">
                <div class="cpsosofenye">
                </div>
                <div class="cpsosoleft">
                    <a href="javascript:void(0)" onclick="toEdit('/Bug/Edit')"><span>添加新任务</span></a>
                    <a href="javascript:void(0)" onclick="goaction('testpass')"><span>测试通过</span></a>
                    <a href="javascript:void(0)" onclick="goaction('testnopass')"><span>测试不通过</span></a>
                    <a href="javascript:void(0)" onclick="goaction('applytest')"><span>申请测试</span></a>
                </div>
            </div>
            <ul class="tabsClass">
                <li><a href="javascript:void(0)" onclick="goState(0)" class="@(Model.State == 0 ? "selected" : "") ">
                    <span>全部任务</span></a></li>
                <li><a href="javascript:void(0)" onclick="goOperator(@Config.CurrentOperator.UserID,'@Config.CurrentOperator.Name')">
                    <span>我的任务</span></a></li>
                <li><a href="javascript:void(0)" onclick="goState(5)" class="@(Model.State == 5 ? "selected" : "") ">
                    <span>未解决</span></a></li>
                <li><a href="javascript:void(0)" onclick="goState(3)" class="@(Model.State == 3 ? "selected" : "") ">
                    <span>已解决</span></a></li>
                <li><a href="javascript:void(0)" onclick="goState(2)" class="@(Model.State == 2 ? "selected" : "") ">
                    <span>已分配</span></a></li>
                <li><a href="javascript:void(0)" onclick="goState(1)" class="@(Model.State == 1 ? "selected" : "") ">
                    <span>未分配</span></a></li>
                <li><a href="javascript:void(0)" onclick="selectedType(@((int)ArticleType.Task))" class="tab1 @(Model.Type == (int)ArticleType.Task ? "selected" : "") ">
                    <span>任务</span></a></li>
                <li><a href="javascript:void(0)" onclick="selectedType(@((int)ArticleType.Bug))" class="tab1 @(Model.Type == (int)ArticleType.Bug ? "selected" : "") ">
                    <span>BUG</span></a></li>
            </ul>
            <div>
                <table class="tblStyle1">
                    <thead>
                        <tr>
                            <th style="width: 5%;">
                                选择
                            </th>
                            <th style="width: 5%;">
                                序号
                            </th>
                            <th style="width: 10%;">
                                项目
                            </th>
                            <th style="width: 35%;">
                                标题
                            </th>
                            <th style="width: 5%;">
                                提出人
                            </th>
                            <th style="width: 10%;">
                                提出日期
                            </th>
                            <th style="width: 5%;">
                                处理人
                            </th>
                            <th style="width: 5%;">
                                测试
                            </th>
                            <th style="width: 5%;">
                                状态
                            </th>
                            <th style="width: 15%;">
                                操作
                            </th>
                        </tr>
                    </thead>
                    @{                        
                                                                         ArticleBLL articleBLL = new ArticleBLL();
                    }
                    @foreach (Article ar in Model.Articles)
                    {
                        Account account = BusinessFactory.Account.GetAccount(ar.OperatorID);
                        @TaskRow(ar, 0);

                                       IList<Article> ars1 = articleBLL.GetArticleByParentID(ar.ID);
                                       foreach (Article ar1 in ars1)
                                       {
                        @TaskRow(ar1, 1);
                                        IList<Article> ars2 = articleBLL.GetArticleByParentID(ar1.ID);
                                        foreach (Article ar2 in ars2)
                                        {
                        @TaskRow(ar2, 2);
                                        }
                                       }
                    }
                </table>
                @Html.RenderPageNav(Model.PageIndex, Model.PageSize, Model.RowCount, "", PageNavStyle.Form)
            </div>
        </div>
    }
    @helper TaskRow(Article art, int level)
        { 
        <tr class="State_@(art.State)">
            <td>
                <input id="ArticleIDs" name="ArticleIDs" type="checkbox" value="@art.ID" />
            </td>
            <td>
                @art.ID
            </td>
            <td>
                @if (level == 0)
                {
                    @art.ProjectIDStr()
                }
            </td>
            <td title="@art.Content" class="child_task_@(level)">
                <a href="javascript:void(0)" onclick="openTab('查看任务','/Bug/View?ID=@art.ID',false)">@art.Title</a>
                @if (art.IsTop == 1)
                {
                    <span style="color: Red"><sub>顶</sub></span>
                }
            </td>
            <td>
                @art.CreateUserName
            </td>
            <td>
                @art.CreateTime.ToShortDateString()
            </td>
            <td>
                @art.OperatorName
            </td>
            <td title="@art.TestResultStr() @art.Tester @art.TestTime"  class="c">
                <span class="testresult_@(art.TestResult)"></span>
            </td>
            <td class="c">
                @art.StateStr()
            </td>
            <td>
                <a href="javascript:void(0)" onclick="toEdit('/Bug/Edit?ParentID=@art.ID')">
                    子任务</a> <a href="javascript:void(0)" onclick="toEdit('/Bug/Edit?ID=@art.ID')">
                        编辑</a> <a href="javascript:void(0)" onclick="Delete('delete',@art.ID)">删除</a>
            </td>
        </tr>
    }
</body>
</html>
